package cn.tannn.ops.nginx.controller.dto;

import cn.tannn.jdevelops.annotations.jpa.JpaSelectIgnoreField;
import cn.tannn.jdevelops.annotations.jpa.JpaSelectOperator;
import cn.tannn.jdevelops.annotations.jpa.enums.SQLConnect;
import cn.tannn.jdevelops.annotations.jpa.enums.SQLOperatorWrapper;
import cn.tannn.jdevelops.jpa.request.PagingSorteds;
import cn.tannn.jdevelops.result.bean.SerializableBean;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import lombok.*;

/**
 * 分页查询域名
 *
 * @author tn
 * @date 2021-06-10 16:03
 */
@Schema(description = "分页查询域名")
@ToString
@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DomainPage extends SerializableBean<DomainPage> {

    /**
     * 域名
     */
    @Schema(description = "域名")
    @JpaSelectOperator(operatorWrapper = SQLOperatorWrapper.LIKE, connect = SQLConnect.AND)
    private String domain;


    /**
     * 分页排序
     */
    @Schema(description = "分页排序")
    @Valid
    @JpaSelectIgnoreField
    private PagingSorteds page;


    public PagingSorteds getPage() {
        if(page == null){
            return new PagingSorteds().fixSort(0,"expiryAfter");
        }
        return page.append(0,"expiryAfter");
    }
}
